<template>
  <div>
    <div>父子组件间通信</div>
    <hr>
    <Child :money='money' @send-money='getMoney' />
  </div>
</template>
<script>
import Child from './views/Child.vue'
import { ref, provide } from 'vue'

export default {
  name: 'App',
  components: { Child },
  setup () {
    const money = ref(100)

    // 把数据提供给子孙组件
    provide('num', 1000)

    provide('get-num', (result) => {
      console.log(result)
    })

    // 接收子组件传递回来的参数
    const getMoney = (m) => {
      console.log(m)
    }
    return { money, getMoney }
  }
}
</script>
